<!--入库单统计表-->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
	</head>
	<style type="text/css">
		#fm {
			text-align: center;
		}
	</style>

	<body style="padding: 0px;">
		<div id="toolbar" class="receipts_toolbar_style"></div>
		<div class="easyui-layout" style="width:100%;height:550px;">
			<div id="div_search" data-options="region:'north'" style="height:120px;"></div>
			<div data-options="region:'center'">
				<div id="p" class="easyui-panel" style="width:100%;height:100%;padding:0px;">
					<div>
						<table id="dg" style="width: 100%;" class="table_style">
						</table>
					</div>
				</div>
			</div>
		</div>
		<div id="div_dialog" class="easyui-dialog" closed="true" style="width: 400px;height: 320px;padding: 20px 20px;">
			<form id="fm" method="post"></form>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src="../../../JS/FrozenShareFunction/FrozenBuildDialogSearch.js"></script>
	<script type="text/javascript">
		var globelOption = '';
		var pageType = getID();
		//0-表示全部都查  1-表示按客户名称查询  2- 表示按仓库名称查询
		var excelLoadUrl = "";
		var searchType = "";
		var columnsData = [];
		Pageini(pageType); //初始化页面的相关参数
		//		var searchType =SEARCH_GOODS+SEARCH_TENANT_NAME+SEARCH_STOREHOUSE_NAME;
		//		searchType+=SEARCH_WAREHOUSE_IN_TIME_START+SEARCH_WAREHOUSE_IN_TIME_END;
		$("#div_search").append(constructSearchOptionFormat(searchType, ""));
		var content = buildSearchOptions(searchType, "");
		$("#fm").append(content);
		content = AddReceiptsToolBar(1152, ""); /**根据用户的权限，来决定生成ToolBar的哪些功能**/
		$("#toolbar").append(content); /*在ID=toolbar的标记后面添加content中的内容*/
		$('#dg').datagrid({
			// url: RemoteLinkAddress + '/logistics/salesorder/findbydetail.do',
			method: 'get',
			rownumbers: 'true',
			pagination: 'true',
			autoRowHeight: 'true',
			fitColumns: 'false',
			singleSelect: 'true',
			height: 350,
			/*表格中的列名以及各自列名的ID*/
			columns: columnsData,
			//			onDblClickRow: function(index, row) {
			//				var pLocation = "";
			//				pLocation = "UI/LOGISTICS/SellOrder/SellOrderAdd.html?id=" + row.ID;
			//				AddTabIn("销售订单详情", parent.$("#tabs"), pLocation);
			//			},
		});
		$("#div_dialog").dialog({
			title: "查询",
			width: 400,
			height: 320,
		});

		function searchmore() {
			$('#div_dialog').dialog('open').dialog('center').dialog('setTitle', '查询');
			$('#fm').form('clear');
			$('#ff').form('clear');
		}

		function doSearch() {
			$("#div_dialog").dialog('close');
			var searchCondition = processSearchCondition(true);
			var _url = RemoteLinkAddress + '/frozen/inorder/list.do?' + searchCondition;
			globelOption = searchCondition;
			getRemoteData(_url);
		}

		function getRemoteData(_url) {
			$.ajax({
				type: "get",
				url: _url,
				dataType: 'json',
				success: function(result) {
					$('#dg').datagrid('options').url = _url;
					$('#dg').datagrid('reload');
				},
				error: function(error) {

				}
			});
		}

		//导出
		function exportExcel() {
			var _url = RemoteLinkAddress + excelLoadUrl;
			if(globelOption.length > 0) {
				_url += '?' + globelOption;
			}
			$.messager.confirm("提示", "确认导出Excel表格吗？", function(r) {
				if(r) {
					$.ajax({ //调用ajax方法，从服务器获取到该订单的所有数据
						type: "get",
						dataType: "json", //服务器返回的数据类型
						url: _url,
						success: function(result) {
							window.location.href = result.path;
						}, //请求成功后，接受服务器传来的Json字符串，并做相应的处理
						error: function(xhr, status, error) {
							$.messager.alert("错误", "请求失败!");
						}
					});
				}
			});
		}

		function closeForm() {
			$("#div_dialog").dialog('close');
		}

		function Pageini(pageType) {
			columnsData = [
				[{
						field: 'IN_DATE',
						title: '单据日期',
						width: '10%',
						align: 'center',
					},
					{
						field: 'ORDER_NO',
						title: '单据编号',
						width: '10%',
						align: 'center',
					},
					{
						field: 'STOREHOUSE_NAME',
						title: '仓库',
						width: '8%',
						align: 'center',
					}, {
						field: 'TENANT_NAME',
						title: '客户',
						width: '8%',
						align: 'center',
					},
					{
						field: 'GOODS_NAME',
						title: '商品名',
						width: '8%',
						align: 'center',
					},
					{
						field: 'SPEC',
						title: '规格',
						width: '10%',
						align: 'center',
					}, {
						field: 'AMOUNT',
						title: '入库数量',
						width: '8%',
						align: 'center',
					},
					{
						field: 'PARTNER1',
						title: '合伙人1',
						width: '8%',
						align: 'center',
					},
					{
						field: 'PARTNER2',
						title: '合伙人2',
						width: '8%',
						align: 'center',
					}, {
						field: 'PARTNER3',
						title: '合伙人3',
						width: '8%',
						align: 'center',
					},
				]
			];
			
			switch(pageType) {
				case "0":
					searchType = SEARCH_TENANT_NAME + SEARCH_STOREHOUSE_NAME;
					excelLoadUrl = "/frozen/inorder/excel/time.do";
					break;
				case "1":
					searchType = SEARCH_TENANT_NAME;
					excelLoadUrl = "/frozen/inorder/excel/tenant.do";
					break;
				case "2":
					searchType = SEARCH_STOREHOUSE_NAME;
					excelLoadUrl = "/frozen/inorder/excel/storehouse.do";
					break;
			}
			searchType += SEARCH_GOODS + SEARCH_WAREHOUSE_IN_TIME_START + SEARCH_WAREHOUSE_IN_TIME_END;
		}
	</script>

</html>